<html>
<head>
	<meta charset="UTF-8">
	<meta content="IE=edge" http-equiv="X-UA-Compatible">
	<meta content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no, width=device-width" name="viewport">
	<title>4368：[IOI2015]boxes纪念品盒</title>
	<!-- css -->
	<link href="../css/base.min.css" rel="stylesheet">
	<link href="../css/project.min.css" rel="stylesheet">
	
	<!-- favicon -->
	<!-- ... -->
</head>
<body class="page-brand">
	<header class="header header-transparent header-waterfall ui-header">
		<ul class="nav nav-list pull-left">
			<li>
				<a data-toggle="menu" href="#menu">
					<span class="icon icon-lg">menu</span>
				</a>
			</li>
		</ul>
		<a class="header-logo header-affix-hide margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[IOI2015]boxes纪念品盒</a>
		<span class="header-logo header-affix margin-left-no margin-right-no" data-offset-top="213" data-spy="affix">[IOI2015]boxes纪念品盒</span>
	</header>
	<nav aria-hidden="true" class="menu" id="menu" tabindex="-1">
		<div class="menu-scroll">
			<div class="menu-content">
				<a class="menu-logo" href="../index.html">BZOJ离线题库</a>
				<ul class="nav">
					<li>
						<a class="waves-attach" data-toggle="collapse" href="#problems">题目</a>
						<ul class="menu-collapse collapse in" id="problems">
							<li>
								<a class="waves-attach" href="../index.html">主页</a>
							</li>
							<li>
								<a class="waves-attach" href="../list.html">题目列表</a>
							</li>
						</ul>
					</li>
					<li>
						<a class="collapsed waves-attach" data-toggle="collapse" href="#about">关于</a>
						<ul class="menu-collapse collapse" id="about">
							<li>
								<a class="waves-attach" href="../about.html">关于此项目</a>
							</li>
						</ul>
					</li>
					
				</ul>
			</div>
		</div>
	</nav>
	<main class="content">
		<div class="content-header ui-content-header">
			<div class="container">
				<h1 class="content-heading">
                [IOI2015]boxes纪念品盒                </h1>
                <p>时间限制：10s&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;  空间限制：1500MB</p>			</div>
		</div>
		<div class="container">
			<section class="content-inner margin-top-no">
				<div class="row">
					<div class="col-lg-13 col-md-13">
						<div class="card margin-bottom-no">
							<div class="card-main">
								<div class="card-inner">
									
                                <h3>题目描述</h3><p><p><span lang="EN-US" style="font-size:12.0pt;font-family:宋体">IOI2015</span><span style="font-size:12.0pt;font-family:宋体">开幕式正在进行最后一个环节。按计划在开幕式期间，每个代表队都将收到由主办方发放的一个装有纪念品的盒子。然而所有志愿者都被精彩的开幕式所吸引，除<span lang="EN-US">Aman</span>外其他人完全忘记了发放纪念品这件事。<span lang="EN-US">Aman</span>是一位热情的志愿者，为使得<span lang="EN-US">IOI</span>尽量圆满，他要用最短的时间将所有纪念品发放出去。</span></p>
<p><!--[if gte mso 9]><xml>
<w:LatentStyles DefLockedState="false" LatentStyleCount="156">
</w:LatentStyles>
</xml><![endif]--><!--[if !mso]><object
classid="clsid:38481807-CA0E-42D2-BF39-B33AF135CC4D" id=ieooui></object>
<style>
st1\:*{behavior:url(#ieooui) }
</style>
<![endif]--><!--[if gte mso 10]>
<style>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:普通表格;
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin:0cm;
mso-para-margin-bottom:.0001pt;
mso-pagination:widow-orphan;
font-size:10.0pt;
font-family:"Times New Roman";
mso-fareast-font-family:"Times New Roman";
mso-ansi-language:#0400;
mso-fareast-language:#0400;
mso-bidi-language:#0400;}
</style>
<![endif]--></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体">开幕式的场地是一个圆环，被分为 个完全相等的区域，这些区域的编号依次为 到，也就是说，对于<span lang="EN-US">0</span></span><span lang="EN-US" style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:Cambria">&le;i&le;L-2</span><span lang="EN-US" style="font-size:12.0pt;font-family:宋体">,</span><span style="font-size:12.0pt;font-family:宋体">区域<span lang="EN-US">i</span>与区域<span lang="EN-US">i+1</span>相邻，且区域<span lang="EN-US">L-1</span>与区域<span lang="EN-US">0</span>相邻。场地上共有<span lang="EN-US">N</span>个代表队，每队坐在上面的一个区域上，每个区域可以包含任意多个代表队，也可以为空。</span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体">共有<span lang="EN-US">N</span>个相同的纪念品。开始，<span lang="EN-US">Aman</span>和所有纪念品都在区域<span lang="EN-US">0</span>。<span lang="EN-US">Aman</span>应该给每队一个纪念品，并且在发放完最后一个纪念品后他必须回到区域<span lang="EN-US">0</span>。注意，有些队可能坐在区域<span lang="EN-US">0</span>。</span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体">在任意时刻，<span lang="EN-US">Aman</span>只能够携带至多<span lang="EN-US">K</span>个纪念品。<span lang="EN-US">Aman</span>必须从区域<span lang="EN-US">0</span>取走这些纪念品，且取纪念品不需要时间。纪念品一旦从区域<span lang="EN-US">0</span>被取走后，<span lang="EN-US">Aman</span>只能将其发放给某个代表队或者随身携带。无论何时，<span lang="EN-US">Aman</span>携带一个或更多的纪念品到达一个这样的区域，该区域有一个代表队尚未收到纪念品，<span lang="EN-US">Aman</span>便可将他携带的一个纪念品发给这个代表队。这种发放也在瞬间完成。他所花的时间都消耗在区域之间的移动上。无论携带多少纪念品，<span lang="EN-US">Aman</span>都需要<span lang="EN-US">1</span>秒钟从一个区域移动到其相邻的区域（可以顺时针移动也可以逆时针移动）。</span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体">你的任务是计算出<span lang="EN-US">Aman</span>发放完所有纪念品并返回到他的最初区域所需要的最短时间（秒数）。</span><span lang="PT-BR" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria;mso-ansi-language:PT-BR"><br />
</span></p>
<p></p></p><hr/><h3>输入格式</h3><p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:
Cambria">第一行</span><span lang="PT-BR" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria;mso-ansi-language:PT-BR">: N K L</span></p>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:
Cambria">第二行</span><span lang="FR" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria;mso-ansi-language:FR">: positions[0] </span><span style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:Cambria;mso-ansi-language:
FR">&hellip;<span lang="FR"> positions[N-1]</span></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria">N: </span><span style="font-size:12.0pt;
font-family:宋体;mso-bidi-font-family:Cambria">代表队的数目。</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria">K: Aman</span><span style="font-size:12.0pt;
font-family:宋体;mso-bidi-font-family:Cambria">在同一时间能够携带纪念品的最大数目。</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria">L: </span><span style="font-size:12.0pt;
font-family:宋体;mso-bidi-font-family:Cambria">开幕式场地上的区域数目。</span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria">positions: </span><span style="font-size:12.0pt;
font-family:宋体;mso-bidi-font-family:Cambria">一个长度为<span lang="EN-US">N</span>的数组，<span lang="EN-US">positions[0],...,positions[N-1]</span>给出了所有代表队所在区域的编号。<span lang="EN-US">positions </span>的元素按非递减排序。</span><span lang="EN-US" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria"><br />
</span></p></p><hr/><h3>输出格式</h3><p><p class="MsoNormal"><span style="font-size:12.0pt;font-family:宋体;mso-bidi-font-family:
Cambria">一个整数，表示<span lang="EN-US">Aman </span>能够完成这一任务所需的最短时间（秒数）。</span><span lang="EN-US" style="font-size:12.0pt;font-family:宋体;
mso-bidi-font-family:Cambria"><br />
</span></p></p><hr/><h3>样例输入</h3><pre>3 2 8
1 2 5</pre><hr/><h3>样例输出</h3><pre>10</pre><hr/><h3>提示</h3><p><p><img width="581" height="366" src="../file/4368_0.gif" alt="" /></p></p><hr/><h3>题目来源</h3><p>鸣谢yts1999上传</p>
								</div>
							</div>
						</div>
					</div>
				</div>
				
				
			</section>
		</div>
	</main>

	<div class="fbtn-container">
		<div class="fbtn-inner">
			<a class="fbtn fbtn-lg fbtn-brand-accent waves-attach waves-circle waves-light waves-effect" data-toggle="dropdown" aria-expanded="true"><span class="fbtn-text fbtn-text-left">Menu</span><span class="fbtn-ori icon">apps</span><span class="fbtn-sub icon">close</span></a>
			<div class="fbtn-dropup">
				<a class="fbtn fbtn-brand waves-attach waves-circle waves-light waves-effect" href="../list.html" target="_self"><span class="fbtn-text fbtn-text-left">题目列表</span><span class="icon">menu</span></a>
				<a class="fbtn fbtn-green waves-attach waves-circle waves-effect" href="../index.html" target="_self"><span class="fbtn-text fbtn-text-left">返回主页</span><span class="icon">home</span></a>
				<a class="fbtn waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/submitpage.php?id=4368" target="_blank"><span class="fbtn-text fbtn-text-left">提交代码</span><span class="icon">send</span></a>
				<a class="fbtn fbtn-orange waves-attach waves-circle waves-effect" href="http://www.lydsy.com/JudgeOnline/wttl/wttl.php?pid=4368" target="_blank"><span class="fbtn-text fbtn-text-left">试题讨论</span><span class="icon">chat</span></a>
				
			</div>
		</div>
	</div>

	<!-- js -->
	<script src="../js/jquery.min.js"></script>
	<script src="../js/base.min.js"></script>
	<script src="../js/project.min.js"></script>
</body>
</html>